package cn.liuwenlin.mq.activemqspringboot.controller;

import cn.liuwenlin.mq.activemqspringboot.service.MessagePublishService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.jms.JMSException;

/**
 * @author 276834
 */
@RestController
public class MainController {

    @Autowired
    MessagePublishService publishService;

    @ResponseBody
    @RequestMapping("send")
    public String send(){
        try {
            publishService.send("activemq", "default topic msg hello");
            publishService.sendTopic("springboot", "auto msg");
            publishService.sendToQueue("activemq", "queue msg world");
        } catch (JMSException e) {
            e.printStackTrace();
        }
        return "ok";
    }

}
